package test1225;

public class Test02 {
    public static void main(String[] args) {

        int[] arr = {1,2,3,4,5};

        // 返回最大值
        int max = m1(arr);
        System.out.println(max);

        // 返回最小值
        int min = m2(arr);
        System.out.println(min);

        // 返回平均值
        double avg = m3(arr);
        System.out.println(avg);

    }
    public static int m1(int[] arr){
        int max = 0;
        for(int i = 0; i < arr.length; i++){
            if(arr[i]>max){
                max = arr[i];
            }
        }
        return max;
    }
    public static int m2(int[] arr){
        int min = 0;
        for(int i = 0; i < arr.length; i++){
            if(arr[i]<min){
                min = arr[i];
            }
        }
        return min;
    }
    public static double m3(int[] arr){
        int sum = 0;
        for(int i = 0;i<arr.length; i++){
            sum = sum + arr[i];
        }
        double avg = sum/arr.length;
        return avg;
    }
}
